/**
 * Description:
 * Class Name:synchronizedTest
 * Date:2022/5/20 10:49
 *
 * @author LTisme
 * @version JAVA17
 */
package Java元动力.多线程.synchronized方法;

public class synchronizedTest {
    public synchronized void say(){
        System.out.println("hello");
    }
    public synchronized static void say2() throws InterruptedException {
        Thread.sleep(200);
        System.out.println("hello2");
    }

    public static void main(String[] args) {
        for (int i = 0; i < 50; i++) {
            new Thread(()->{
                try {
                    say2();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("------" + Math.random() + "------");
            }).start();
        }
    }
}
